<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noodp" />
    <title class="pjax-title">Hugo搭建博客 - </title><meta name="Description" content=""><meta property="og:title" content="Hugo搭建博客" />
<meta property="og:description" content="linux环境，hugo搭建博客教程" />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://gzhcoming.gitee.io/posts/create_blog/" /><meta property="og:image" content="https://s2.loli.net/2022/02/12/91RPBC8XSyYsFnj.png" /><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2022-02-12T09:53:17+08:00" />
<meta property="article:modified_time" content="2022-02-12T09:53:17+08:00" />

<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="https://s2.loli.net/2022/02/12/91RPBC8XSyYsFnj.png"/>

<meta name="twitter:title" content="Hugo搭建博客"/>
<meta name="twitter:description" content="linux环境，hugo搭建博客教程"/>
<meta name="application-name" content="">
<meta name="apple-mobile-web-app-title" content="">

<meta name="theme-color" content="#f8f8f8"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="canonical" href="http://gzhcoming.gitee.io/posts/create_blog/" /><link rel="prev" href="http://gzhcoming.gitee.io/posts/third/" /><link rel="next" href="http://gzhcoming.gitee.io/posts/081-utilities/" /><link rel="stylesheet" href="/lib/normalize/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" href="/lib/fontawesome-free/all.min.css">
        <noscript><link rel="stylesheet" href="/lib/fontawesome-free/all.min.css"></noscript><link rel="preload" as="style" onload="this.onload=null;this.rel='stylesheet'" href="/lib/animate/animate.min.css">
        <noscript><link rel="stylesheet" href="/lib/animate/animate.min.css"></noscript><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "Hugo搭建博客",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "http:\/\/gzhcoming.gitee.io\/posts\/create_blog\/"
        },"genre": "posts","wordcount":  896 ,
        "url": "http:\/\/gzhcoming.gitee.io\/posts\/create_blog\/","datePublished": "2022-02-12T09:53:17+08:00","dateModified": "2022-02-12T09:53:17+08:00","publisher": {
            "@type": "Organization",
            "name": "作者"},"author": {
                "@type": "Person",
                "name": "作者"
            },"description": ""
    }
    </script></head>

<body header-desktop="" header-mobile=""><script type="text/javascript">
        function setTheme(theme) {document.body.setAttribute('theme', theme);}
        function saveTheme(theme) {window.localStorage && localStorage.setItem('theme', theme);}
        function getMeta(metaName) {const metas = document.getElementsByTagName('meta'); for (let i = 0; i < metas.length; i++) if (metas[i].getAttribute('name') === metaName) return metas[i]; return '';}
        if (window.localStorage && localStorage.getItem('theme')) {let theme = localStorage.getItem('theme');theme === 'light' || theme === 'dark' || theme === 'black' ? setTheme(theme) : (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? setTheme('dark') : setTheme('light')); } else { if ('' === 'light' || '' === 'dark' || '' === 'black') setTheme(''), saveTheme(''); else saveTheme('auto'), window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? setTheme('dark') : setTheme('light');}
        let metaColors = {'light': '#f8f8f8','dark': '#252627','black': '#000000'}
        getMeta('theme-color').content = metaColors[document.body.getAttribute('theme')];
    </script>
    <div id="back-to-top"></div>
    <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title=""><span id="desktop-header-typeit" class="typeit"></span></a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> 文章 </a><a class="menu-item" href="/tags/"> 标签 </a><a class="menu-item" href="/series/"> 系列 </a><a class="menu-item" href="/about/"> 关于 </a><span class="menu-item delimiter"></span><a href="#" onclick="return false;" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a></div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title=""><span id="mobile-header-typeit" class="typeit"></span></a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><a class="menu-item" href="/posts/" title="">文章</a><a class="menu-item" href="/tags/" title="">标签</a><a class="menu-item" href="/series/" title="">系列</a><a class="menu-item" href="/about/" title="">关于</a><a href="#" onclick="return false;" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
            <div class="container"><div class="toc" id="toc-auto">
        <h2 class="toc-title">目录</h2>
        <div class="toc-content" id="toc-content-auto"><nav id="TableOfContents">
  <ul>
    <li><a href="#安装hugo">安装hugo</a></li>
    <li><a href="#新建站点">新建站点</a></li>
    <li><a href="#安装主题">安装主题</a></li>
    <li><a href="#配置主题文件">配置主题文件</a></li>
    <li><a href="#预览效果">预览效果</a></li>
    <li><a href="#图床选择">图床选择</a></li>
    <li><a href="#部署到gitee">部署到gitee</a></li>
  </ul>
</nav></div>
    </div><script>document.getElementsByTagName("main")[0].setAttribute("pageStyle", "normal")</script><script>document.getElementsByTagName("main")[0].setAttribute("autoTOC", "true")</script><article class="page single"><h1 class="single-title animate__animated animate__flipInX">Hugo搭建博客</h1><div class="post-meta">
            <div class="post-meta-line">
                <span class="post-author"><i class="author fas fa-user-circle fa-fw"></i><a href="/" title="Author" rel=" author" class="author">作者</a>
                </span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2022-02-12">2022-02-12</time>&nbsp;<i class="far fa-edit fa-fw"></i>&nbsp;<time datetime="2022-02-12">2022-02-12</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 896 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 2 分钟&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li><a href="#安装hugo">安装hugo</a></li>
    <li><a href="#新建站点">新建站点</a></li>
    <li><a href="#安装主题">安装主题</a></li>
    <li><a href="#配置主题文件">配置主题文件</a></li>
    <li><a href="#预览效果">预览效果</a></li>
    <li><a href="#图床选择">图床选择</a></li>
    <li><a href="#部署到gitee">部署到gitee</a></li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><h1 id="linux环境下hugo--smms--gitee-配置博客" class="headerLink">
    <a href="#linux%e7%8e%af%e5%a2%83%e4%b8%8bhugo--smms--gitee-%e9%85%8d%e7%bd%ae%e5%8d%9a%e5%ae%a2" class="header-mark"></a>linux环境下hugo + sm.ms + gitee 配置博客</h1><h2 id="安装hugo" class="headerLink">
    <a href="#%e5%ae%89%e8%a3%85hugo" class="header-mark"></a>安装hugo</h2><pre tabindex="0"><code>snap install hugo --channel=extended
</code></pre><p>如果没有 snap就安装snap：apt install snap<!-- raw HTML omitted -->
因为下面主题原因，需要使用扩展版的 hugo<!-- raw HTML omitted --></p>
<pre tabindex="0"><code>hugo version  #查看hugo的版本,有些主题会有对hugo的版本做出要求
</code></pre><h2 id="新建站点" class="headerLink">
    <a href="#%e6%96%b0%e5%bb%ba%e7%ab%99%e7%82%b9" class="header-mark"></a>新建站点</h2><pre tabindex="0"><code>hugo new site 你的博客源文件文件名
</code></pre><p>例如 hugo new site test</p>
<h2 id="安装主题" class="headerLink">
    <a href="#%e5%ae%89%e8%a3%85%e4%b8%bb%e9%a2%98" class="header-mark"></a>安装主题</h2><pre tabindex="0"><code>cd test // 进入你的博客源文件
git clone https://github.com/HEIGE-PCloud/DoIt.git themes/DoIt //下载DoIt主题
</code></pre><h2 id="配置主题文件" class="headerLink">
    <a href="#%e9%85%8d%e7%bd%ae%e4%b8%bb%e9%a2%98%e6%96%87%e4%bb%b6" class="header-mark"></a>配置主题文件</h2><p>把配置文档覆盖到config.toml里，注意是<strong>博客根目录</strong>的config.toml。<!-- raw HTML omitted -->
该<a href="https://hugodoit.pages.dev/zh-cn/theme-documentation-basics/" target="_blank" rel="noopener noreffer">主题</a>的最简运行配置为：</p>
<pre tabindex="0"><code>baseURL = &#34;http://example.org/&#34;
# [en, zh-cn, fr, ...] 设置默认的语言
defaultContentLanguage = &#34;zh-cn&#34;
# 网站语言, 仅在这里 CN 大写
languageCode = &#34;zh-CN&#34;
# 是否包括中日韩文字
hasCJKLanguage = true
# 网站标题
title = &#34;我的全新 Hugo 网站&#34;

# 更改使用 Hugo 构建网站时使用的默认主题
theme = &#34;DoIt&#34;

[params]
  # DoIt 主题版本
  version = &#34;0.2.X&#34;

[menu]
  [[menu.main]]
    identifier = &#34;posts&#34;
    # 你可以在名称 (允许 HTML 格式) 之前添加其他信息, 例如图标
    pre = &#34;&#34;
    # 你可以在名称 (允许 HTML 格式) 之后添加其他信息, 例如图标
    post = &#34;&#34;
    name = &#34;文章&#34;
    url = &#34;/posts/&#34;
    # 当你将鼠标悬停在此菜单链接上时, 将显示的标题
    title = &#34;&#34;
    weight = 1
  [[menu.main]]
    identifier = &#34;tags&#34;
    pre = &#34;&#34;
    post = &#34;&#34;
    name = &#34;标签&#34;
    url = &#34;/tags/&#34;
    title = &#34;&#34;
    weight = 2
  [[menu.main]]
    identifier = &#34;categories&#34;
    pre = &#34;&#34;
    post = &#34;&#34;
    name = &#34;分类&#34;
    url = &#34;/categories/&#34;
    title = &#34;&#34;
    weight = 3

# Hugo 解析文档的配置
[markup]
  # 语法高亮设置 (https://gohugo.io/content-management/syntax-highlighting)
  [markup.highlight]
    # false 是必要的设置 (https://github.com/dillonzq/LoveIt/issues/158)
    noClasses = false
</code></pre><h2 id="预览效果" class="headerLink">
    <a href="#%e9%a2%84%e8%a7%88%e6%95%88%e6%9e%9c" class="header-mark"></a>预览效果</h2><pre tabindex="0"><code>hugo server //然后在浏览器打开 localhost:1313 预览效果
</code></pre><h2 id="图床选择" class="headerLink">
    <a href="#%e5%9b%be%e5%ba%8a%e9%80%89%e6%8b%a9" class="header-mark"></a>图床选择</h2><p>使用<a href="https://sm.ms/" target="_blank" rel="noopener noreffer">sm.ms</a>作为图床，免费使用。
将图片上传到次网站，即可自动生成引用的格式，十分的便利。</p>
<h2 id="部署到gitee" class="headerLink">
    <a href="#%e9%83%a8%e7%bd%b2%e5%88%b0gitee" class="header-mark"></a>部署到gitee</h2><p>1 新建仓库，根据<a href="" rel="">要求</a>,仓库的名字必须是自己的账号名<br>
2 逐步输入以下命令，因为生成的页面放到public目录下，所以是推送public里面的内容，并不会公开源文件。</p>
<pre tabindex="0"><code>cd 博客根目录
hugo --theme=DoIt --baseUrl=&#34;http://你的账号名.gitee.io/&#34;
cd public
git init
git remote add origin https://gitee.com/gzhcoming/gzhcoming.git
git add -A
git commit -m &#34;first commit&#34;
git push -u origin master
</code></pre><p>3 到该gitee项目中，开启gitee pages服务。<!-- raw HTML omitted --><br>
4 每次重新将该静态页面推送到gitee上，都需要在pages服务进行重新部署(即<strong>更新</strong>按钮)。<!-- raw HTML omitted --><br>
5 每次更新的时候，都进行页面的编译生成，即上述第二天命令。<br>
注意：现在的gitee开启 page服务，需要进行实名认证。</p>
</div>

        <div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2022-02-12</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"></div>
            <div class="post-info-share">
                <span><a href="#" onclick="return false;" title="分享到 Twitter" data-sharer="twitter" data-url="http://gzhcoming.gitee.io/posts/create_blog/" data-title="Hugo搭建博客"><i class="fab fa-twitter fa-fw"></i></a><a href="#" onclick="return false;" title="分享到 Facebook" data-sharer="facebook" data-url="http://gzhcoming.gitee.io/posts/create_blog/"><i class="fab fa-facebook-square fa-fw"></i></a><a href="#" onclick="return false;" title="分享到 Hacker News" data-sharer="hackernews" data-url="http://gzhcoming.gitee.io/posts/create_blog/" data-title="Hugo搭建博客"><i class="fab fa-hacker-news fa-fw"></i></a><a href="#" onclick="return false;" title="分享到 Line" data-sharer="line" data-url="http://gzhcoming.gitee.io/posts/create_blog/" data-title="Hugo搭建博客"><i data-svg-src="/lib/simple-icons/icons/line.min.svg"></i></a><a href="#" onclick="return false;" title="分享到 微博" data-sharer="weibo" data-url="http://gzhcoming.gitee.io/posts/create_blog/" data-title="Hugo搭建博客"><i class="fab fa-weibo fa-fw"></i></a><a href="#" onclick="return false;" title="分享到 Telegram" data-sharer="telegram" data-url="http://gzhcoming.gitee.io/posts/create_blog/" data-title="Hugo搭建博客" data-web><i class="fab fa-telegram-plane fa-fw"></i></a></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/posts/third/" class="prev" rel="prev" title="学习列表"><i class="fas fa-angle-left fa-fw"></i>学习列表</a>
            <a href="/posts/081-utilities/" class="next" rel="next" title="081 Utilities">081 Utilities<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
</article></div>
        </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">
                    由 <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.96.0">Hugo</a> 强力驱动&nbsp;|&nbsp;主题 - <a href="https://github.com/HEIGE-PCloud/DoIt" target="_blank" rel="noopener noreffer" title="DoIt 0.2.13"><i class="far fa-edit fa-fw"></i> DoIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2022</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank" rel="noopener noreferrer"></a></span></div>
            <div class="footer-line"></div>
            <div class="footer-line">
            </div>
        </div></footer></div>

    <div id="fixed-buttons"><a href="#back-to-top" id="back-to-top-button" class="fixed-button" title="回到顶部">
            <i class="fas fa-arrow-up fa-fw"></i>
        </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
            <i class="fas fa-comment fa-fw"></i>
        </a>
    </div><div class="assets"><script type="text/javascript" src="/lib/lazysizes/lazysizes.min.js"></script><script type="text/javascript" src="/lib/topbar/topbar.min.js"></script><script type="text/javascript" src="/lib/pjax/pjax.min.js"></script><script type="text/javascript" src="/js/theme.min.js"></script></div>

<div class="pjax-assets"><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":10},"comment":{},"data":{"desktop-header-typeit":"Gzh's blog","mobile-header-typeit":"Gzh's blog"},"sharerjs":true,"typeit":{"cursorChar":null,"cursorSpeed":null,"data":{"desktop-header-typeit":["desktop-header-typeit"],"mobile-header-typeit":["mobile-header-typeit"]},"duration":null,"speed":null}};</script><script type="text/javascript" src="/lib/clipboard/clipboard.min.js"></script><script type="text/javascript" src="/lib/sharer/sharer.min.js"></script><script type="text/javascript" src="/lib/typeit/typeit.min.js"></script></div>
</body>

</html>